package com.atstudying.mall.order.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author Mr.zhneg
 * @create 2020-11-21-12:40
 */
//订单确认页需要的数据

public class OrderConfirmVo {

    @Getter @Setter
    //收货地址 ums_member_receive_address表
    List<MemberAddressVo> address;
    @Getter @Setter

    //所有选中的购物项
    List<OrderItemVo> items;
    @Getter @Setter

    //发票信息
    //优惠劵信息
    Integer integer;
    @Getter @Setter
    Map<Long,Boolean> stocks;
    BigDecimal total;//订单总额

    public BigDecimal getTotal() {

        BigDecimal sum = new BigDecimal(0);
        if (items!=null) {
            for (OrderItemVo item : items
                    ) {

                BigDecimal peritems = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum= sum.add(peritems);
            }


        }
        return sum;
    }

     Integer count;
      BigDecimal payPrice;//应付价格
    public BigDecimal getPayPrice() {

        BigDecimal sum = new BigDecimal(0);
        if (items!=null) {
            for (OrderItemVo item : items
                    ) {

                BigDecimal peritems = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum= sum.add(peritems);
            }


        }
        return sum;
    }

    public Integer getCount(){
        Integer i=0;
        if (items!=null){
            for (OrderItemVo item:items){
                i+=item.getCount();
            }
        }
        return i;
    }
    //防重令牌
    @Getter @Setter
    String orderToken;
}


